﻿<?xml version="1.0" encoding="utf-8"?>
<!--
    Rules are processed in the following order:

        Entities - Replace named entities with their numeric equivalent.

        MarkupWrapper - Replace HTML tags with a placeholder in the text so as
        not to alter their content in later processing.

        Remove - This will get rid of HTML tags with no MAML equivalent.

        Replace - Replace HTML tags with their MAML equivalents.

    The following tags are handled based on their context after the above
    processing and are not handled in any of the rules noted above:

        a       Converted to an appropriate link based on context.
        code    Replaced with "codeInline" or "code" based on context.
        h1-h6   Converted to sections with the appropriate format.
        img     Converted to an appropriate image link based on context.
        see     Converted to a roughly equivalent codeEntityReference.

    Once done, the MarkupWrapper placeholders are replaced with their markup
    enclosed in <markup> and </markup> tags.
-->

<ConversionRules>
  <!-- This defines the regular expression used to extract the body text from
       a file.  By default it extracts the <body> (.html files) or <bodyText>
       (.topic files) element content. The body part of the expression must be
       a named group called "Body". -->
  <BodyExtract expression="&lt;\s*body(Text)?[^&gt;]*?&gt;(?&lt;Body&gt;.*?)&lt;\s*/\s*body(Text)?\s*&gt;" />

  <!-- Named entities not recognized by the .NET XML parser are replaced
       with their numeric equivalent. -->
  <Entities>
    <Entity name="Aacute" value="193" />
    <Entity name="aacute" value="225" />
    <Entity name="Acirc" value="194" />
    <Entity name="acirc" value="226" />
    <Entity name="acute" value="180" />
    <Entity name="AElig" value="198" />
    <Entity name="aelig" value="230" />
    <Entity name="Agrave" value="192" />
    <Entity name="agrave" value="224" />
    <Entity name="Aring" value="197" />
    <Entity name="aring" value="229" />
    <Entity name="Atilde" value="195" />
    <Entity name="atilde" value="227" />
    <Entity name="Auml" value="196" />
    <Entity name="auml" value="228" />
    <Entity name="brvbar" value="166" />
    <Entity name="Ccedil" value="199" />
    <Entity name="ccedil" value="231" />
    <Entity name="cedil" value="184" />
    <Entity name="cent" value="162" />
    <Entity name="copy" value="169" />
    <Entity name="curren" value="164" />
    <Entity name="deg" value="176" />
    <Entity name="divide" value="247" />
    <Entity name="Eacute" value="201" />
    <Entity name="eacute" value="233" />
    <Entity name="Ecirc" value="202" />
    <Entity name="ecirc" value="234" />
    <Entity name="Egrave" value="200" />
    <Entity name="egrave" value="232" />
    <Entity name="ETH" value="208" />
    <Entity name="eth" value="240" />
    <Entity name="Euml" value="203" />
    <Entity name="euml" value="235" />
    <Entity name="frac12" value="189" />
    <Entity name="frac14" value="188" />
    <Entity name="frac34" value="190" />
    <Entity name="Iacute" value="205" />
    <Entity name="iacute" value="237" />
    <Entity name="Icirc" value="206" />
    <Entity name="icirc" value="238" />
    <Entity name="iexcl" value="161" />
    <Entity name="Igrave" value="204" />
    <Entity name="igrave" value="236" />
    <Entity name="iquest" value="191" />
    <Entity name="Iuml" value="207" />
    <Entity name="iuml" value="239" />
    <Entity name="laquo" value="171" />
    <Entity name="macr" value="175" />
    <Entity name="micro" value="181" />
    <Entity name="middot" value="183" />
    <Entity name="nbsp" value="160" />
    <Entity name="not" value="172" />
    <Entity name="Ntilde" value="209" />
    <Entity name="ntilde" value="241" />
    <Entity name="Oacute" value="211" />
    <Entity name="oacute" value="243" />
    <Entity name="Ocirc" value="212" />
    <Entity name="ocirc" value="244" />
    <Entity name="Ograve" value="210" />
    <Entity name="ograve" value="242" />
    <Entity name="ordf" value="170" />
    <Entity name="ordm" value="186" />
    <Entity name="Oslash" value="216" />
    <Entity name="oslash" value="248" />
    <Entity name="Otilde" value="213" />
    <Entity name="otilde" value="245" />
    <Entity name="Ouml" value="214" />
    <Entity name="ouml" value="246" />
    <Entity name="para" value="182" />
    <Entity name="plusmn" value="177" />
    <Entity name="pound" value="163" />
    <Entity name="raquo" value="187" />
    <Entity name="reg" value="174" />
    <Entity name="sect" value="167" />
    <Entity name="shy" value="173" />
    <Entity name="sup1" value="185" />
    <Entity name="sup2" value="178" />
    <Entity name="sup3" value="179" />
    <Entity name="szlig" value="223" />
    <Entity name="THORN" value="222" />
    <Entity name="thorn" value="254" />
    <Entity name="times" value="215" />
    <Entity name="Uacute" value="218" />
    <Entity name="uacute" value="250" />
    <Entity name="Ucirc" value="219" />
    <Entity name="ucirc" value="251" />
    <Entity name="Ugrave" value="217" />
    <Entity name="ugrave" value="249" />
    <Entity name="uml" value="168" />
    <Entity name="Uuml" value="220" />
    <Entity name="uuml" value="252" />
    <Entity name="Yacute" value="221" />
    <Entity name="yacute" value="253" />
    <Entity name="yen" value="165" />
    <Entity name="yuml" value="255" />
  </Entities>

  <!-- Wrap these tags in markup elements for manual review -->
  <MarkupWrapper>
    <Tag name="applet" />
    <Tag name="bgsound" />
    <Tag name="button" />
    <Tag name="embed" />
    <Tag name="fieldset" />
    <Tag name="form" />
    <Tag name="frameset" />
    <Tag name="iframe" />
    <Tag name="ilayer" />
    <Tag name="input" />
    <Tag name="label" />
    <Tag name="layer" />
    <Tag name="map" />
    <Tag name="noembed" />
    <Tag name="nolayer" />
    <Tag name="noscript" />
    <Tag name="object" />
    <Tag name="script" />
    <Tag name="select" />
    <Tag name="sound" />
    <Tag name="textarea" />
    <Tag name="xml" />
  </MarkupWrapper>

  <!-- Remove these tags and expressions as they have no MAML equivalent if
       they appear outside of the wrapped elements above. -->
  <Remove>
    <Tag name="area" />
    <Tag name="base" />
    <Tag name="basefont" />
    <Tag name="bdo" />
    <Tag name="blink" />
    <Tag name="center" />
    <Tag name="col" />
    <Tag name="colgroup" />
    <Tag name="del" />
    <Tag name="font" />
    <Tag name="frame" />
    <Tag name="include" />
    <Tag name="ins" />
    <Tag name="isindex" />
    <Tag name="keygen" />
    <Tag name="legend" />
    <Tag name="link" />
    <Tag name="marquee" />
    <Tag name="meta" />
    <Tag name="multicol" />
    <Tag name="nextid" />
    <Tag name="nobr" />
    <Tag name="noframes" />
    <Tag name="optgroup" />
    <Tag name="option" />
    <Tag name="param" />
    <Tag name="plaintext" />
    <Tag name="rt" />
    <Tag name="ruby" />
    <Tag name="s" />
    <Tag name="spacer" />
    <Tag name="strike" />
    <Tag name="style" />
    <Tag name="tbody" />
    <Tag name="tfoot" />
    <Tag name="wbr" />
  </Remove>

  <!-- Replace these tags with their closest MAML equivalent.  For tags with
       Match elements, if the found tag matches one of the expressions,
       the given attributes will be used.  If no match is found, the attributes
       on the parent element are used.  If startTag isn't specified, the tag
       is effectively removed.  If endTag is not specified, the startTag
       value is used for the closing tag.  If an "attributes" value is not
       specified, all attributes are removed.  If specified, the new values
       replace any existing attributes unless "@Preserve" is specified.  In
       that case, the existing attributes, if any, are retained. -->
  <Replace>
    <Tag name="abbr" startTag="phrase" />
    <Tag name="acronym" startTag="phrase" />
    <Tag name="address" startTag="phrase" />
    <Tag name="b" startTag="legacyBold" />
    <Tag name="big" startTag="legacyBold" />
    <Tag name="blockquote" startTag="quote" />
    <Tag name="br" startTag="&lt;para/&gt;" />
    <Tag name="caption" startTag="title" />
    <Tag name="cite" startTag="phrase" />
    <Tag name="comment" startTag="&lt;--" endTag="--&gt;" />
    <Tag name="dd" startTag="definition" />
    <Tag name="dfn" startTag="newTerm" />
    <Tag name="dir" startTag="list" attributes="class=&quot;bullet&quot;" />

    <Tag name="div">
      <!-- If a match for 'class="deprecated"' is found, replace it with
           an alert.  If not matched, the element is removed. -->
      <Match expression="class=&quot;deprecated&quot;" startTag="alert"
        attributes="class=&quot;warning&quot;" />
    </Tag>

    <Tag name="dl" startTag="definitionTable" />
    <Tag name="dt" startTag="definedTerm" />
    <Tag name="em" startTag="legacyItalic" />
    <Tag name="hr" startTag="&lt;para/&gt;" />
    <Tag name="i" startTag="legacyItalic" />
    <Tag name="inlineinput" startTag="userInput" />
    <Tag name="kbd" startTag="userInput" />
    <Tag name="li" startTag="listItem" />
    <Tag name="listing" startTag="code" />
    <Tag name="menu" startTag="list" attributes="class=&quot;bullet&quot;" />
    <Tag name="ol" startTag="list" attributes="class=&quot;ordered&quot;" />
    <Tag name="p" startTag="para" />

    <!-- Replace pre tags with a code element with no language or title. -->
    <Tag name="pre" startTag="code" attributes="language=&quot;none&quot; title=&quot; &quot;">
      <!-- However, if a lang/language attribute is defined, preserve
           the HTML attributes. -->
      <Match expression="lang(uage)?=" startTag="code" attributes="@Preserve" />
    </Tag>

    <Tag name="q" startTag="quoteInline" />
    <Tag name="samp" startTag="computerOutputInline" />
    <Tag name="small" startTag="superscript" />

    <!-- Like div, replace span if possible based on class or remove it -->
    <Tag name="span">
      <Match expression="class=&quot;code&quot;" startTag="codeInline" />
      <Match expression="class=&quot;command&quot;" startTag="command" />
      <Match expression="class=&quot;foreignPhrase&quot;" startTag="foreignPhrase" />
      <Match expression="class=&quot;input&quot;" startTag="userInput" />
      <Match expression="class=&quot;italic&quot;" startTag="legacyItalic" />
      <Match expression="class=&quot;label&quot;" startTag="legacyBold" />
      <Match expression="class=&quot;literalValue&quot;" startTag="computerOutputInline" />
      <Match expression="class=&quot;math&quot;" startTag="math" />
      <Match expression="class=&quot;noLink&quot;" startTag="legacyBold" />
      <Match expression="class=&quot;parameter&quot;" startTag="replaceable" />
      <Match expression="class=&quot;phrase&quot;" startTag="phrase" />
      <Match expression="class=&quot;placeholder&quot;" startTag="placeholder" />
      <Match expression="class=&quot;selfLink&quot;" startTag="legacyBold" />
      <Match expression="class=&quot;term&quot;" startTag="newTerm" />
      <Match expression="class=&quot;ui&quot;" startTag="ui" />
    </Tag>

    <Tag name="spell" startTag="legacyUnderline" />
    <Tag name="strong" startTag="legacyBold" />
    <Tag name="sub" startTag="subscript" />
    <Tag name="sup" startTag="superscript" />
    <Tag name="table" startTag="table" />
    <Tag name="td" startTag="entry" />
    <Tag name="th" startTag="entry" />
    <Tag name="thead" startTag="tableHeader" />
    <Tag name="tr" startTag="row" />
    <Tag name="tt" startTag="computerOutputInline" />
    <Tag name="u" startTag="legacyUnderline" />
    <Tag name="ul" startTag="list" attributes="class=&quot;bullet&quot;" />
    <Tag name="var" startTag="replaceable" />
    <Tag name="xmp" startTag="code" />
  </Replace>
</ConversionRules>
